import basegraphunit from './basegraphunit.js'
import coorPkg from '../../struct/coord.js'

class Rectangle extends basegraphunit.BaseGraphUnit {
    constructor() {
        super();
        this.pos = new coorPkg.MultiPos();
        this.strPosition = "";
        this.titleZoneFlag = false;
        this.symbolEdgeFlag = false;
    }

    translateSubInfo(tx,ty){
        this.strPosition = this.pos.toString();
    }

    toJson() {
        var jsonobj = {};
        super.toJson(jsonobj);
        jsonobj["strPosition"] = this.pos.toString();
        jsonobj["titleZoneFlag"] = this.titleZoneFlag;
        jsonobj["symbolEdgeFlag"] = this.symbolEdgeFlag;
        return jsonobj;
    }
    fromJson(jsonobj) {
        super.fromJson(jsonobj);
        var sx = jsonobj["sx"];
        var sy = jsonobj["sy"];
        if (sx != null && sy != null) {
            this.pos.setPosByString(sx, sy);
        }
        else {
            this.strPosition = jsonobj["strPosition"];
            this.pos.fromString(this.strPosition);
        }
        this.titleZoneFlag = jsonobj["titleZoneFlag"];
        this.symbolEdgeFlag = jsonobj["symbolEdgeFlag"];
    }
    cloneCopy() {
        var pNewInfo = new Rectangle();
        super.cloneCopy(pNewInfo);
        pNewInfo.titleZoneFlag = this.titleZoneFlag;
        pNewInfo.symbolEdgeFlag = this.symbolEdgeFlag;
        return pNewInfo;
    }
}

export default { Rectangle }